<template>
  <div class="search-bar">
    <el-form :inline="true" :model="formItem" class="form-filter" size="mini">
      <el-form-item>
        <el-radio-group v-model="formItem.s_category" @change="search">
          <el-radio-button key="all" label="">全部</el-radio-button>
          <el-radio-button key="day" label="day">日巡检</el-radio-button>
          <el-radio-button key="regular" label="regular">健康巡检</el-radio-button>
          <!-- <el-radio-button key="service" label="service">重保服务</el-radio-button> -->
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-select v-model="formItem.s_itemType" clearable placeholder="请选择巡检类别" size="mini" @change="search">
          <el-option v-for="(item) in types" :key="item.code" :label="item.text " :value="item.code" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-input
          v-model="formItem.s_item"
          placeholder="请输入巡检项内容"
          clearable
          size="mini"
          @keyup.enter.native="search"
          @change="onGlobeSearchInputChange"
        />
      </el-form-item>
      <el-form-item>
        <el-button plain icon="el-icon-search" @click="search" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { findByDictionaryType } from '@neu/dcom-ui/api/dictionary'
// 定义一个查询表单原始项
const formItem = {
  s_category: '',
  s_itemType: '',
  s_item: ''
}

export default {
  name: 'HnInspectionFilter',
  data() {
    return {
      formItem: {
        ...formItem
      },
      /** 巡检类别 */
      types: [],
      /** 存储时间范围 */
      timeRangeCreateTimeStart: []

    }
  },
  created() {
    findByDictionaryType('hnInspectionItemType').then(res => {
      if (res.status === 'success') {
        this.types = res.data
      }
    })
  },
  mounted() {
  },
  methods: {
    // 查询按钮点击事件处理
    search: function() {
      this.$parent.filter(this.formItem)
    },
    // 重置按钮点击事件处理
    reset: function() {
      this.formItem = {
        ...formItem
      }
      this.search()
    },
    onChange: function(val) {
      this.$parent.onResize()
    },
    onGlobeSearchInputChange(value) {
      if (value === '') {
        this.search()
      }
    }
  }
}
</script>
